/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sales.seesion.stateless;

import company.entity.Company;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import sales.entity.Product;

@Stateless
@LocalBean
public class ProductManageSessionBean {

    @PersistenceContext(unitName = "MerlionFoodERP-ejbPU")
    private EntityManager em;
    private Product product;

    public void saveNewProduct(List<String> productNameList,  List<Double>  basicPriceList,  List<Double> promotionPriceList) {
        product=new Product();
    
        product.setProductName(productNameList.get(0));
        product.setBasePrice(basicPriceList.get(0));
        product.setPromotionPrice(promotionPriceList.get(0));
        em.persist(product);
        
        product=new Product();
        
        product.setProductName(productNameList.get(1));
        product.setBasePrice(basicPriceList.get(1));
        product.setPromotionPrice(promotionPriceList.get(1));
        em.persist(product);
        
         product=new Product();
         
        product.setProductName(productNameList.get(2));
        product.setBasePrice(basicPriceList.get(2));
        product.setPromotionPrice(promotionPriceList.get(2));
        em.persist(product);
        
         product=new Product();
        
        product.setProductName(productNameList.get(3));
        product.setBasePrice(basicPriceList.get(3));
        product.setPromotionPrice(promotionPriceList.get(3));
        em.persist(product);
        
    }

    public Product getProductById(Long id) {
        return em.find(Product.class, id);
    }
}
